<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理员列表 - 志愿服务管理系统</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <style>
        :root {
            --primary-color: #337ab7;
            --hover-color: #286090;
            --bg-gradient: linear-gradient(145deg, var(--primary-color), var(--hover-color));
            --shadow: 0 2px 10px rgba(0,0,0,0.1);
            --transition: all 0.3s ease;
            --border-radius: 10px;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
            min-height: 100vh;
            padding: 20px;
        }

        .main-container {
            max-width: 1200px;
            margin: 0 auto;
        }

        .card {
            background: white;
            border-radius: var(--border-radius);
            box-shadow: var(--shadow);
            margin-bottom: 30px;
            border: none;
        }

        .card-header {
            background: var(--bg-gradient);
            color: white;
            padding: 1.5rem;
            border-radius: var(--border-radius) var(--border-radius) 0 0;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .card-header h2 {
            margin: 0;
            font-size: 1.5rem;
            font-weight: 600;
        }

        .table {
            margin: 0;
        }

        .table th {
            background: #f8f9fa;
            font-weight: 600;
            padding: 1rem;
            border-bottom: 2px solid #dee2e6;
        }

        .table td {
            padding: 1rem;
            vertical-align: middle;
        }

        .table tbody tr {
            transition: var(--transition);
        }

        .table tbody tr:hover {
            background-color: #f8f9fa;
            transform: translateY(-2px);
            box-shadow: var(--shadow);
        }

        .badge {
            padding: 0.5rem 1rem;
            border-radius: 20px;
            font-weight: 500;
        }

        .badge-admin {
            background: #198754;
            color: white;
        }

        .badge-super {
            background: #dc3545;
            color: white;
        }

        .btn-action {
            padding: 0.5rem 1rem;
            border-radius: 5px;
            color: white;
            text-decoration: none;
            margin: 0 5px;
            transition: var(--transition);
        }

        .btn-edit {
            background: #ffc107;
        }

        .btn-delete {
            background: #dc3545;
        }

        .btn-action:hover {
            transform: translateY(-2px);
            box-shadow: var(--shadow);
            color: white;
        }

        .btn-back {
            background: white;
            color: var(--primary-color);
            padding: 0.5rem 1rem;
            border-radius: 5px;
            text-decoration: none;
            transition: var(--transition);
        }

        .btn-back:hover {
            background: rgba(255,255,255,0.9);
            transform: translateY(-2px);
        }

        .pagination {
            margin-top: 20px;
            justify-content: center;
            gap: 5px;
        }

        .page-link {
            border-radius: 5px;
            color: var(--primary-color);
            padding: 0.5rem 1rem;
            transition: var(--transition);
        }

        .page-link:hover {
            background: var(--primary-color);
            color: white;
            transform: translateY(-2px);
        }

        .page-item.active .page-link {
            background: var(--primary-color);
            border-color: var(--primary-color);
        }

        .page-info {
            text-align: center;
            color: #6c757d;
            margin-top: 1rem;
        }

        .password-mask {
            font-family: monospace;
            letter-spacing: 2px;
        }

        @media (max-width: 768px) {
            .table-responsive {
                overflow-x: auto;
            }

            .btn-action {
                padding: 0.4rem 0.8rem;
                font-size: 0.9rem;
            }

            .card-header {
                flex-direction: column;
                gap: 1rem;
                text-align: center;
            }
        }
    </style>
</head>
<body>
<div class="main-container">
    <div class="card">
        <div class="card-header">
            <h2><i class="fas fa-users-cog me-2"></i>管理员列表</h2>
            <a href="#" th:href="@{/toSuperAdminPage}" class="btn-back">
                <i class="fas fa-arrow-left me-2"></i>返回
            </a>
        </div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table">
                    <thead>
                    <tr>
                        <th>ID</th>
                        <th>昵称</th>
                        <th>账号</th>
                        <th>密码</th>
                        <th>身份</th>
                        <th>发布活动次数</th>
                        <th>注册时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="admin : ${admins}">
                        <td th:text="${admin.getId()}"></td>
                        <td th:text="${admin.getNickname()}"></td>
                        <td th:text="${admin.getMobile()}"></td>
                        <td class="password-mask">••••••••</td>
                        <td>
                                    <span th:class="'badge ' + (${admin.getRole() == 'super'} ? 'badge-super' : 'badge-admin')"
                                          th:text="${admin.getRole()}">
                                    </span>
                        </td>
                        <td th:text="${admin.getPublish()}"></td>
                        <td th:text="${#dates.format(admin.getRegisterDate(), 'yyyy-MM-dd HH:mm')}"></td>
                        <td>
                            <a th:href="@{'/updateAdminPage/' + ${admin.getId()}}"
                               class="btn-action btn-edit"
                               title="编辑">
                                <i class="fas fa-edit"></i>
                            </a>
                            <a th:href="@{'/deleteAdmin/' + ${admin.getId()}}"
                               class="btn-action btn-delete"
                               title="删除"
                               onclick="return confirm('确定要删除这个管理员吗？');">
                                <i class="fas fa-trash"></i>
                            </a>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <!-- 分页导航 -->
    <nav th:if="${totalPages > 1}" aria-label="Page navigation">
        <ul class="pagination">
            <li class="page-item" th:classappend="${currentPage == 1} ? 'disabled'">
                <a class="page-link" th:href="@{/adminList(currentPage=1)}">
                    <i class="fas fa-angle-double-left"></i>
                </a>
            </li>
            <li class="page-item" th:classappend="${currentPage == 1} ? 'disabled'">
                <a class="page-link" th:href="@{/adminList(currentPage=${currentPage - 1})}">
                    <i class="fas fa-angle-left"></i>
                </a>
            </li>

            <li class="page-item" th:each="pageNum : ${#numbers.sequence(1, totalPages)}"
                th:classappend="${pageNum == currentPage} ? 'active'">
                <a class="page-link" th:href="@{/adminList(currentPage=${pageNum})}"
                   th:text="${pageNum}"></a>
            </li>

            <li class="page-item" th:classappend="${currentPage == totalPages} ? 'disabled'">
                <a class="page-link" th:href="@{/adminList(currentPage=${currentPage + 1})}">
                    <i class="fas fa-angle-right"></i>
                </a>
            </li>
            <li class="page-item" th:classappend="${currentPage == totalPages} ? 'disabled'">
                <a class="page-link" th:href="@{/adminList(currentPage=${totalPages})}">
                    <i class="fas fa-angle-double-right"></i>
                </a>
            </li>
        </ul>
        <div class="page-info">
            <span>第 [[${currentPage}]] 页</span>
            <span class="mx-2">|</span>
            <span>共 [[${totalPages}]] 页</span>
        </div>
    </nav>
</div>

<!-- Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>